package com.ruoyi.zhgd.domain.vo;

import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
import com.ruoyi.common.annotation.Dict;

import lombok.Data;

import java.math.BigDecimal;
import java.math.RoundingMode;


/**
 * 项目产量统计列表对象
 *
 * @author zyb
 * @date 2023-09-06
 */
@Data
@ExcelIgnoreUnannotated
public class NAsphaltQualityStatisticsVo {

    private static final long serialVersionUID = 1L;

    private String deptId;
    private String deptName;

    /**
     * 拌合楼
     *
     * @return
     */
    private String stationName;

    /**
     * 级配类型
     */
    private String matchType;

    /**
     * 配方名称
     */
    private String matchName;

    /**
     * 配方编号
     */
    private String matchCode;

    /**
     * 项目名称
     */
    private String projectName;

    /**
     * 摊铺层级
     */
    private String pavingLevel;

    /**
     * 摊铺层级
     */
    @Dict(dicCodeField = "pavingLevel", dictCodeId = "PAVING_LEVEL")
    private String pavingLevelLabel;

    /**
     * 生产批次
     */
    private Integer number;

    /**
     * 重量
     */
    private Double weight;

    /**
     * 平均油石比
     */
    private Double asphaltAggregateRatioAvg;

    /**
     * 设计油石比
     */
    private Double asphaltAggregateRatio;

    /**
     * 平均温度
     */
    private Double temperatureAvg;

    /**
     * 设计温度
     */
    private String temperature;

    /**
     * 最大温度
     */
    private BigDecimal temperatureMax;

    /**
     * 最小温度
     */
    private BigDecimal temperatureMin;

    /**
     * 不合格重量
     */
    private Double alarmWeight;

    /**
     * 不合格批次
     */
    private Integer alarmNumber;

    /**
     * 温度预警数量
     */
    private Integer temperatureAlarm;

    /**
     * 温度预警比例
     */
    private BigDecimal temperatureAlarmRatio;

    /**
     * 油石比预警数量
     */
    private Integer asphaltAggregateRatioAlarm;

    /**
     * 油石比预警比例
     */
    private BigDecimal asphaltAggregateRatioAlarmRatio;

    /**
     * 筛孔预警数量
     */
    private Integer sieveAlarm;

    /**
     * 筛孔预警比例
     */
    private BigDecimal sieveAlarmRatio;

    public String getTemperature() {
        String max = null == temperatureMax ? "0" : temperatureMax.stripTrailingZeros().toEngineeringString();
        String min = null == temperatureMin ? "0" : temperatureMin.stripTrailingZeros().toEngineeringString();
        if("0".equals(min) && "0".equals(max)) {
            return null;
        }
        if("0".equals(min) && !"0".equals(max)) {
            return max;
        }
        if(!"0".equals(min) && "0".equals(max)) {
            return min;
        }
        if (max.equals(min)) {
            return max;
        }
        return min + "~" + max;
    }

    public BigDecimal getTemperatureAlarmRatio() {
        if (null == number || 0 == number || null == temperatureAlarm || 0 == temperatureAlarm) {
            temperatureAlarmRatio = BigDecimal.ZERO;
        } else {
            temperatureAlarmRatio = new BigDecimal(temperatureAlarm * 100).divide(new BigDecimal(number), 2,
                RoundingMode.HALF_UP);
        }
        return temperatureAlarmRatio;
    }

    public BigDecimal getAsphaltAggregateRatioAlarmRatio() {
        if (null == number || 0 == number || null == asphaltAggregateRatioAlarm || 0 == asphaltAggregateRatioAlarm) {
            asphaltAggregateRatioAlarmRatio = BigDecimal.ZERO;
        } else {
            asphaltAggregateRatioAlarmRatio = new BigDecimal(asphaltAggregateRatioAlarm * 100)
                .divide(new BigDecimal(number), 2, RoundingMode.HALF_UP);
        }
        return asphaltAggregateRatioAlarmRatio;
    }

    public BigDecimal getSieveAlarmRatio() {
        if (null == number || 0 == number || null == sieveAlarm || 0 == sieveAlarm) {
            sieveAlarmRatio = BigDecimal.ZERO;
        } else {
            sieveAlarmRatio = new BigDecimal(sieveAlarm * 100).divide(new BigDecimal(number), 2, RoundingMode.HALF_UP);
        }
        return sieveAlarmRatio;
    }
}
